--- import Breadcrumbs from '@/components/Breadcrumbs.astro' import Link from '@/components/Link.astro' import PostHead from '@/components/PostHead.astro' import PostNavigation from '@/components/PostNavigation.astro' import SubpostsHeader from '@/components/SubpostsHeader.astro' import SubpostsSidebar from '@/components/SubpostsSidebar.astro' import TOCHeader from '@/components/TOCHeader.astro' import TOCSidebar from '@/components/TOCSidebar.astro' import { badgeVariants } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import Layout from '@/layouts/Layout.astro' import { getAdjacentPosts, getAllPostsAndSubposts, getCombinedReadingTime, getParentId, getParentPost, getPostReadingTime, getSubpostCount, getTOCSections, hasSubposts, isSubpost, parseAuthors, } from '@/lib/data-utils' import { formatDate } from '@/lib/utils' import { Icon } from 'astro-icon/components' import { Image } from 'astro:assets' import { render } from 'astro:content' export async function getStaticPaths() { const posts = await getAllPostsAndSubposts() return posts.map((post) => ({ params: { id: post.id }, props: post, })) } const post = Astro.props const currentPostId = Astro.params.id const { Content, headings } = await render(post) const authors = await parseAuthors(post.data.authors ?? []) const isCurrentSubpost = isSubpost(currentPostId) const navigation = await getAdjacentPosts(currentPostId) const parentPost = isCurrentSubpost ? await getParentPost(currentPostId) : null const hasChildPosts = await hasSubposts(currentPostId) const subpostCount = !isCurrentSubpost ? await getSubpostCount(currentPostId) : 0 const postReadingTime = await getPostReadingTime(currentPostId) const combinedReadingTime = hasChildPosts && !isCurrentSubpost ? await getCombinedReadingTime(currentPostId) : null const tocSections = await getTOCSections(currentPostId) --- { (hasChildPosts || isCurrentSubpost) && ( ) } { headings?.length > 0 && !( isCurrentSubpost && headings.length === 1 && headings[0].text === post.data.title ) && }
{ post.data.image && ( {post.data.title} ) }

{post.data.title}

{ authors.length > 0 && (
{authors.map((author) => (
{author.name} {author.isRegistered ? ( {author.name} ) : ( {author.name} )}
))}
) }
{formatDate(post.data.date)}
{postReadingTime} { combinedReadingTime && combinedReadingTime !== postReadingTime && ( {' '} ({combinedReadingTime} total) ) }
{ subpostCount > 0 && (
{subpostCount} subpost{subpostCount === 1 ? '' : 's'}
) }
{ post.data.tags && post.data.tags.length > 0 && post.data.tags.map((tag) => ( {tag} )) }
{ tocSections.length > 0 && ( ) }
{ (hasChildPosts || isCurrentSubpost) && ( ) }